﻿using Set_File_Rw;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.IO.Ports;
using System.Windows;
using System;
using System.Windows.Input;
using TestFireBroadcastingHostPhone.RecordData;
using TestFireBroadcastingHostPhone.Source;

namespace TestFireBroadcastingHostPhone.ViewModel
{
    public class SystemConfigMV : ViewModelBase
    {
        /// <summary>
        /// 配置文件保存路径
        /// </summary>
        public const string configpath = "C:\\盈帜软件配置\\RecordData\\RelatedRecord.ini";
        public static SystemConfigMV systemconfigMV { get; private set; }
        /// <summary>
        /// 测试数量
        /// </summary>
        public int TestNumber = 0;
        /// <summary>
        /// 测试合格数量
        /// </summary>
        public int SuccessTestNumber = 0;
        /// <summary>
        /// 自动测试命令配置
        /// </summary>
        public enum Test_CmdConfig : byte
        {
            /// <summary>
            /// 屏蔽区域控制，屏蔽本机地址
            /// </summary>
            Cmd_ShieldControlAndAddress = 0,
            /// <summary>
            /// 隐藏区域控制控制，保留本机地址
            /// </summary>
            Cmd_ShieldControl_SaveAddress = 1,
            /// <summary>
            /// 保留区域控制和本机地址
            /// </summary>
            Cmd_SaveControlAndAddress = 2,
            /// <summary>
            /// 不配置
            /// </summary>
            Cmd_NoneConfig = 3,
        }


        public SystemConfigMV()
        {
            systemconfigMV = this;
            ACPowerSources = new ObservableCollection<string>
            {
                "旧程控交流源",
                "新程控交流源"
            };
        }
        /// <summary>
        /// 窗体载入事件
        /// </summary>
        /// <param name="obj"></param>
        public void SystemConfig_Loaded()
        {
            string err_info = string.Empty;
            string default_file_path = Directory.GetCurrentDirectory() + "\\RecordData\\RelatedRecord.ini";
            try
            {
                Cmb_FrockSerialPort_SelectValue = Set_Data_Rw.Read(configpath, default_file_path, "工装串口", out err_info);
                Cmb_AN97002SerialPort_SelectValue = Set_Data_Rw.Read(configpath, default_file_path, "交流源串口", out err_info);
                Cmb_HostPhoneSerialPort_SelectValue = Set_Data_Rw.Read(configpath, default_file_path, "产品串口", out err_info);
                Cmb_485CommunicatePort_SelectValue = Set_Data_Rw.Read(configpath, default_file_path, "485串口", out err_info);
                if (AutoTestConfig.Default.测试人员 == "赵梦涵") IsEnabled_1000HzRange = true;
                else IsEnabled_1000HzRange = false;
                Text_1000HzRange = Set_Data_Rw.Read(configpath, default_file_path, "音频范围", out err_info);
                HostPowerBeyondVoltage = Set_Data_Rw.Read(configpath, default_file_path, "主电过压", out err_info);
                HostPowerRestoreVoltage = Set_Data_Rw.Read(configpath, default_file_path, "主电恢复", out err_info);
                Text_CheckSelfTimer = Set_Data_Rw.Read(configpath, default_file_path, "自检时间", out err_info);
                Text_OscilloscopeIP_Address = Set_Data_Rw.Read(configpath, default_file_path, "示波器IP地址", out err_info);
                Cmb_ACPowerSelect_SelectValue = Set_Data_Rw.Read(configpath, default_file_path, "程控交流源配置", out err_info);

                Cmb_AutoTestCmdConfig_SelectedIndex = int.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机测试命令配置", out err_info));
                IsChecked_Chb_ShieldAmplifier = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机屏蔽功放功能", out err_info));
                IsChecked_Chb_RegisterAmplifier = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机匹配功放功能", out err_info));
                IsChecked_QueryRegisterAmplifier = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机匹配功放查询功能", out err_info));
                IsChecked_ManualTestEmergency = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机手动应急功能", out err_info));
                IsChecked_Chb_CheckSelf = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机自检功能", out err_info));
                IsChecked_UpdateVoiceSource = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机更新字库", out err_info));
                IsChecked_AUX_Change = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机AUX切换功能", out err_info));
                IsChecked_KeyCheck = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机按键测试功能", out err_info));
                IsChecked_Redio = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机录音功能", out err_info));
                IsChecked_Chb_BeyondAndRestoreVoltage = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机满载过压恢复功能", out err_info));
                IsChecked_Chb_AutoTest_ExchangePower = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机主备电切换功能", out err_info));
                IsChecked_Chb_BeyondCurrent = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机满载过流恢复功能", out err_info));
                IsChecked_Chb_FullLoadShortAndRestore = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机满载短路恢复功能", out err_info));
                IsChecked_24vEmergency = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播主机自动应急功能", out err_info));
                IsChecked_SettingAmplifierAddress = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "广播功放设置地址功能", out err_info));
                IsChecked_SQLDataSave = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "测试数据保存功能", out err_info));
                IsChecked_AutoReadCode = bool.Parse(Set_Data_Rw.Read(configpath, default_file_path, "产品自动读码功能", out err_info));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}", "系统配置页面加载错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        /// <summary>
        /// 交流源串口的数据集合
        /// </summary>
        public ObservableCollection<string> Cmb_AN97002SerialPort_ItemsSource { get; set; } = new ObservableCollection<string>();
        /// <summary>
        /// 485串口的数据集合
        /// </summary>
        public ObservableCollection<string> Cmb_485CommunicatePort_ItemsSource { get; set; } = new ObservableCollection<string>();
        /// <summary>
        /// 广播串口的数据集合
        /// </summary>
        public ObservableCollection<string> Cmb_UpdateHostPhoneSerialPort_ItemsSource { get; set; } = new ObservableCollection<string>();
        /// <summary>
        /// 工装串口数据集合
        /// </summary>
        public ObservableCollection<string> Cmb_UpdateFrockSerialPort_ItemsSource { get; set; } = new ObservableCollection<string>();




        /// <summary>
        /// 交流源串口内容
        /// </summary>
        public string? Cmb_AN97002SerialPort_SelectValue { get; set; }
        /// <summary>
        /// 485产品测试串口内容
        /// </summary>
        public string? Cmb_485CommunicatePort_SelectValue { get; set; }
        /// <summary>
        /// 广播串口内容
        /// </summary>
        public string? Cmb_HostPhoneSerialPort_SelectValue { get; set; }
        /// <summary>
        /// 工装串口内容
        /// </summary>
        public string? Cmb_FrockSerialPort_SelectValue { get; set; }
        /// <summary>
        /// 遍历7个串口是否有相同值
        /// </summary>
        /// <returns></returns>
        public bool AreSerialPortsUnique()
        {
            HashSet<string?> serialPorts = new HashSet<string?>
            {
                Cmb_AN97002SerialPort_SelectValue,
                Cmb_485CommunicatePort_SelectValue,
                Cmb_HostPhoneSerialPort_SelectValue,
                Cmb_FrockSerialPort_SelectValue
            };
            // 如果HashSet中元素的数量小于属性数量，则说明存在重复值
            return serialPorts.Count == 4;
        }
        /// <summary>
        /// 绑定交流源串口双击更新事件
        /// </summary>
        public ICommand Cmb_UpdateAN97002HSerialPort_ClickCommand => new RelayCommand(OnCmb_UpdateAN97002HSerialPort_Click);
        /// <summary>
        /// 绑定485产品串口双击更新事件
        /// </summary>
        public ICommand Cmb_Update485CommunicatePort_ClickCommand => new RelayCommand(OnCmb_UpdateCmb_485CommunicatePort_Click);
        /// <summary>
        /// 绑定广播串口双击更新事件
        /// </summary>
        public ICommand Cmb_UpdateHostPhoneSerialPort_ClickCommand => new RelayCommand(OnCmb_UpdateHostPhoneSerialPort_Click);
        /// <summary>
        /// 绑定工装串口双击更新事件
        /// </summary>
        public ICommand Cmb_UpdateFrockSerialPort_ClickCommand => new RelayCommand(OnCmb_UpdateFrockSerialPort_Click);

        /// <summary>
        /// 双击更新交流源串口
        /// </summary>
        /// <param name="obj"></param>
        private void OnCmb_UpdateAN97002HSerialPort_Click(object obj)
        {
            StaticInfo.instrumentsControl.ACPowerPort?.Close();
            StaticInfo.instrumentsControl.ACPowerPort?.Dispose();
            StaticInfo.instrumentsControl.ACPowerPort = null;
            var portNames = SerialPort.GetPortNames();
            Cmb_AN97002SerialPort_ItemsSource.Clear();
            foreach (var port in portNames)
            {
                Cmb_AN97002SerialPort_ItemsSource.Add(port);
            }
            Cmb_AN97002SerialPort_SelectValue = Cmb_AN97002SerialPort_ItemsSource.Count > 0 ? Cmb_AN97002SerialPort_ItemsSource[0] : null;
            OnPropertyChanged(nameof(Cmb_AN97002SerialPort_ItemsSource));
            OnPropertyChanged(nameof(Cmb_AN97002SerialPort_SelectValue));
        }
        /// <summary>
        /// 双击更新485产品串口
        /// </summary>
        /// <param name="obj"></param>
        private void OnCmb_UpdateCmb_485CommunicatePort_Click(object obj)
        {
            string err_info = string.Empty;
            StaticInfo.funProduct.Close_CommunicatePort(out err_info);
            if (string.IsNullOrEmpty(err_info))
            {
                var portNames = SerialPort.GetPortNames();
                Cmb_485CommunicatePort_ItemsSource.Clear();
                foreach (var port in portNames)
                {
                    Cmb_485CommunicatePort_ItemsSource.Add(port);
                }
                Cmb_485CommunicatePort_SelectValue = Cmb_485CommunicatePort_ItemsSource.Count > 0 ? Cmb_485CommunicatePort_ItemsSource[0] : null;
                OnPropertyChanged(nameof(Cmb_485CommunicatePort_ItemsSource));
                OnPropertyChanged(nameof(Cmb_485CommunicatePort_SelectValue));
            }
        }
        /// <summary>
        /// 双击更新广播串口
        /// </summary>
        /// <param name="obj"></param>
        private void OnCmb_UpdateHostPhoneSerialPort_Click(object obj)
        {
            string err_info = string.Empty;
            StaticInfo.funProduct.Close_CommunicatePort(out err_info);
            if (string.IsNullOrEmpty(err_info))
            {
                var portNames = SerialPort.GetPortNames();
                Cmb_UpdateHostPhoneSerialPort_ItemsSource.Clear();
                foreach (var port in portNames)
                {
                    Cmb_UpdateHostPhoneSerialPort_ItemsSource.Add(port);
                }
                Cmb_HostPhoneSerialPort_SelectValue = Cmb_UpdateHostPhoneSerialPort_ItemsSource.Count > 0 ? Cmb_UpdateHostPhoneSerialPort_ItemsSource[0] : null;
                OnPropertyChanged(nameof(Cmb_UpdateHostPhoneSerialPort_ItemsSource));
                OnPropertyChanged(nameof(Cmb_HostPhoneSerialPort_SelectValue));
            }
        }
        /// <summary>
        /// 双击更新工装串口
        /// </summary>
        /// <param name="obj"></param>
        private void OnCmb_UpdateFrockSerialPort_Click(object obj)
        {
            string err_info = string.Empty;
            StaticInfo.frockControl.Close_SerialPort(out err_info);
            if (string.IsNullOrEmpty(err_info))
            {
                var portNames = SerialPort.GetPortNames();
                Cmb_UpdateFrockSerialPort_ItemsSource.Clear();
                foreach (var port in portNames)
                {
                    Cmb_UpdateFrockSerialPort_ItemsSource.Add(port);
                }
                Cmb_FrockSerialPort_SelectValue = Cmb_UpdateFrockSerialPort_ItemsSource.Count > 0 ? Cmb_UpdateFrockSerialPort_ItemsSource[0] : null;
                OnPropertyChanged(nameof(Cmb_UpdateFrockSerialPort_ItemsSource));
                OnPropertyChanged(nameof(Cmb_FrockSerialPort_SelectValue));
            }
        }

        public string _1000HzRange = "95";
        /// <summary>
        /// 测试日志路径
        /// </summary>
        public string Text_1000HzRange
        {
            get => this._1000HzRange;
            set
            {
                this._1000HzRange = value;
                OnPropertyChanged();
            }
        }

        private bool _IsEnabled_1000HzRange = false;
        /// <summary>
        /// 1000Hz音频范围可编辑属性
        /// </summary>
        public bool IsEnabled_1000HzRange
        {
            get => this._IsEnabled_1000HzRange;
            set
            {
                this._IsEnabled_1000HzRange = value;
                OnPropertyChanged();
            }
        }

        public string _UPathVolume = "32";
        /// <summary>
        /// U盘文件音量大小
        /// </summary>
        public string Text_UPathVolume
        {
            get => this._UPathVolume;
            set
            {
                this._UPathVolume = value;
                OnPropertyChanged();
            }
        }

        public string _HostPowerBeyondVoltage = string.Empty;
        /// <summary>
        /// 主电过压参数
        /// </summary>
        public string HostPowerBeyondVoltage
        {
            get => this._HostPowerBeyondVoltage;
            set
            {
                this._HostPowerBeyondVoltage = value;
                OnPropertyChanged();
            }
        }

        public string _HostPowerRestoreVoltage = string.Empty;
        /// <summary>
        /// 主电恢复电压参数
        /// </summary>
        public string HostPowerRestoreVoltage
        {
            get => this._HostPowerRestoreVoltage;
            set
            {
                this._HostPowerRestoreVoltage = value;
                OnPropertyChanged();
            }
        }

        public string _CheckSelfTimer = string.Empty;
        /// <summary>
        /// 自检时间
        /// </summary>
        public string Text_CheckSelfTimer
        {
            get => this._CheckSelfTimer;
            set
            {
                this._CheckSelfTimer = value;
                OnPropertyChanged();
            }
        }

        public string _OscilloscopeIP_Address = string.Empty;
        /// <summary>
        /// 示波器IP地址
        /// </summary>
        public string Text_OscilloscopeIP_Address
        {
            get => this._OscilloscopeIP_Address;
            set
            {
                this._OscilloscopeIP_Address = value;
                OnPropertyChanged();
            }
        }


        public ObservableCollection<string> ACPowerSources { get; set; }

        public string _Cmb_ACPowerSelect_SelectValue;
        /// <summary>
        /// 程控交流源选择内容
        /// </summary>
        public string Cmb_ACPowerSelect_SelectValue
        {
            get => this._Cmb_ACPowerSelect_SelectValue;
            set
            {
                this._Cmb_ACPowerSelect_SelectValue = value;
                OnPropertyChanged();
            }
        }

        /// <summary>
        /// 绑定主电过压参数事件
        /// </summary>
        public ICommand Txt_HostPowerBeyondVoltage_LostFocusCommand => new RelayCommand(OnTxt_HostPowerBeyondVoltage_Click);
        /// <summary>
        /// 绑定主电恢复电压参数事件
        /// </summary>
        public ICommand Txt_HostPowerRestoreVoltage_LostFocusCommand => new RelayCommand(OnTxt_HostPowerRestoreVoltage_Click);
        /// <summary>
        /// 主电过压参数设置事件
        /// </summary>
        /// <param name="obj"></param>
        private void OnTxt_HostPowerBeyondVoltage_Click(object obj)
        {
            string err_info = string.Empty;
            string default_file_path = Directory.GetCurrentDirectory() + "\\RecordData\\RelatedRecord.ini";
            Set_Data_Rw.Write(configpath, default_file_path, "主电过压", HostPowerBeyondVoltage, out err_info);
        }
        /// <summary>
        /// 主电恢复电压设置事件
        /// </summary>
        /// <param name="obj"></param>
        private void OnTxt_HostPowerRestoreVoltage_Click(object obj)
        {
            string err_info = string.Empty;
            string default_file_path = Directory.GetCurrentDirectory() + "\\RecordData\\RelatedRecord.ini";
            Set_Data_Rw.Write(configpath, default_file_path, "主电恢复", HostPowerRestoreVoltage, out err_info);
        }

        public int _Cmb_AutoTestCmdConfig_SelectedIndex;
        /// <summary>
        /// 测试命令配置选择
        /// </summary>
        public int Cmb_AutoTestCmdConfig_SelectedIndex
        {
            get => this._Cmb_AutoTestCmdConfig_SelectedIndex;
            set
            {
                this._Cmb_AutoTestCmdConfig_SelectedIndex = value;
                OnPropertyChanged();
            }
        }

        #region -- CheckBox
        public bool _Chb_AutoTest_ExchangePower;
        /// <summary>
        /// 主备电切换功能选择
        /// </summary>
        public bool IsChecked_Chb_AutoTest_ExchangePower
        {
            get => this._Chb_AutoTest_ExchangePower;
            set
            {
                this._Chb_AutoTest_ExchangePower = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_BeyondAndRestoreVoltage;
        /// <summary>
        /// 满载过压恢复功能选择
        /// </summary>
        public bool IsChecked_Chb_BeyondAndRestoreVoltage
        {
            get => this._Chb_AutoTest_BeyondAndRestoreVoltage;
            set
            {
                this._Chb_AutoTest_BeyondAndRestoreVoltage = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_BeyondCurrent;
        /// <summary>
        /// 满载过流测试功能选择
        /// </summary>
        public bool IsChecked_Chb_BeyondCurrent
        {
            get => this._Chb_AutoTest_BeyondCurrent;
            set
            {
                this._Chb_AutoTest_BeyondCurrent = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_FullLoadShortAndRestore;
        /// <summary>
        /// 满载短路恢复功能选择
        /// </summary>
        public bool IsChecked_Chb_FullLoadShortAndRestore
        {
            get => this._Chb_AutoTest_FullLoadShortAndRestore;
            set
            {
                this._Chb_AutoTest_FullLoadShortAndRestore = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_CheckSelf;
        /// <summary>
        /// 自检功能选择
        /// </summary>
        public bool IsChecked_Chb_CheckSelf
        {
            get => this._Chb_AutoTest_CheckSelf;
            set
            {
                this._Chb_AutoTest_CheckSelf = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_ShieldAmplifier;
        /// <summary>
        /// 屏蔽功放功能选择
        /// </summary>
        public bool IsChecked_Chb_ShieldAmplifier
        {
            get => this._Chb_AutoTest_ShieldAmplifier;
            set
            {
                this._Chb_AutoTest_ShieldAmplifier = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_RegisterAmplifier;
        /// <summary>
        /// 匹配攻放功能选择
        /// </summary>
        public bool IsChecked_Chb_RegisterAmplifier
        {
            get => this._Chb_AutoTest_RegisterAmplifier;
            set
            {
                this._Chb_AutoTest_RegisterAmplifier = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_24vEmergency;
        /// <summary>
        /// 24V自动应急功能选择
        /// </summary>
        public bool IsChecked_24vEmergency
        {
            get => this._Chb_AutoTest_24vEmergency;
            set
            {
                this._Chb_AutoTest_24vEmergency = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_UpdateVoiceSource;
        /// <summary>
        /// 更新字库功能选择
        /// </summary>
        public bool IsChecked_UpdateVoiceSource
        {
            get => this._Chb_AutoTest_UpdateVoiceSource;
            set
            {
                this._Chb_AutoTest_UpdateVoiceSource = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_KeyCheck;
        /// <summary>
        /// 按键检测功能选择
        /// </summary>
        public bool IsChecked_KeyCheck
        {
            get => this._Chb_AutoTest_KeyCheck;
            set
            {
                this._Chb_AutoTest_KeyCheck = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_AUX_Change;
        /// <summary>
        /// AUX切换功能选择
        /// </summary>
        public bool IsChecked_AUX_Change
        {
            get => this._Chb_AutoTest_AUX_Change;
            set
            {
                this._Chb_AutoTest_AUX_Change = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_ManualTestEmergency;
        /// <summary>
        /// 手动应急功能选择
        /// </summary>
        public bool IsChecked_ManualTestEmergency
        {
            get => this._Chb_AutoTest_ManualTestEmergency;
            set
            {
                this._Chb_AutoTest_ManualTestEmergency = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_Redio;
        /// <summary>
        /// 录音测试功能选择
        /// </summary>
        public bool IsChecked_Redio
        {
            get => this._Chb_AutoTest_Redio;
            set
            {
                this._Chb_AutoTest_Redio = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTestQueryRegisterAmplifier;
        /// <summary>
        /// 匹配功放查询功能
        /// </summary>
        public bool IsChecked_QueryRegisterAmplifier
        {
            get => this._Chb_AutoTestQueryRegisterAmplifier;
            set
            {
                this._Chb_AutoTestQueryRegisterAmplifier = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_IsChecked_SQLDataSave;
        /// <summary>
        /// 自动测试数据保存功能
        /// </summary>
        public bool IsChecked_SQLDataSave
        {
            get => this._Chb_IsChecked_SQLDataSave;
            set
            {
                this._Chb_IsChecked_SQLDataSave = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_AutoReadCode;
        /// <summary>
        /// 自动读取代码功能选择
        /// </summary>
        public bool IsChecked_AutoReadCode
        {
            get => this._Chb_AutoTest_AutoReadCode;
            set
            {
                this._Chb_AutoTest_AutoReadCode = value;
                OnPropertyChanged();
            }
        }

        public bool _Chb_AutoTest_SettingAmplifierAddress;
        /// <summary>
        /// 手动设置功放地址功能
        /// </summary>
        public bool IsChecked_SettingAmplifierAddress
        {
            get => this._Chb_AutoTest_SettingAmplifierAddress;
            set
            {
                this._Chb_AutoTest_SettingAmplifierAddress = value;
                OnPropertyChanged();
            }
        }


        public ICommand Chb_AutoTest_AutoReadCode_CheckedCommand => new RelayCommand(OnChb_AutoTest_AutoReadCode_Checked);
        public void OnChb_AutoTest_AutoReadCode_Checked(object parameter)
        {
            string err_info = string.Empty;
            string default_file_path = Directory.GetCurrentDirectory() + "\\RecordData\\RelatedRecord.ini";
            IsChecked_AutoReadCode = true;
            Set_Data_Rw.Write(SystemConfigMV.configpath, default_file_path, "产品自动读码功能", "True", out err_info);
            AutoTestConfig.Default.Save();
        }

        public ICommand Chb_AutoTest_AutoReadCode_UnCheckedCommand => new RelayCommand(OnChb_AutoTest_AutoReadCode_UnChecked);
        public void OnChb_AutoTest_AutoReadCode_UnChecked(object parameter)
        {
            string err_info = string.Empty;
            string default_file_path = Directory.GetCurrentDirectory() + "\\RecordData\\RelatedRecord.ini";
            IsChecked_AutoReadCode = false;
            Set_Data_Rw.Write(SystemConfigMV.configpath, default_file_path, "产品自动读码功能", "False", out err_info);
            AutoTestConfig.Default.Save();
        }
        #endregion
    }
}
